package com.wandian.weather.adapter;


import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.mylib.libcore.bean.LocalCityBean;
import com.mylib.libcore.utils.UIUtils;
import com.wandian.weather.R;

public class WeatherCityRecycleAdapter extends BaseQuickAdapter<LocalCityBean, BaseViewHolder> {

    private String selectItem = "";
    public WeatherCityRecycleAdapter(int layoutResId) {
        super(layoutResId);
    }

    @Override
    protected void convert(BaseViewHolder helper, LocalCityBean item) {
        TextView tv_city_name = helper.getView(R.id.tv_city_name);
        switch (item.getName()){
            case "内蒙古自治区":
                tv_city_name.setText("内蒙古");
                break;
            case "广西壮族自治区":
                tv_city_name.setText("广西");
                break;
            case "新疆维吾尔自治区":
                tv_city_name.setText("新疆");
                break;
            case "宁夏回族自治区":
                tv_city_name.setText("宁夏");
                break;
            case "西藏自治区":
                tv_city_name.setText("西藏");
                break;
            default:
                tv_city_name.setText(item.getName()+"");
                break;
        }

        if(!UIUtils.isEmpty(selectItem) && item.getName().contains(selectItem)){
            tv_city_name.setBackground(mContext.getResources().getDrawable(R.drawable.button_sys_circle_ball));
            tv_city_name.setTextColor(mContext.getResources().getColor(R.color.white));
        }else {
            tv_city_name.setBackground(mContext.getResources().getDrawable(R.drawable.button_line_circle_ball));
            tv_city_name.setTextColor(mContext.getResources().getColor(R.color.colorthree));
        }
    }
    public void notifySelectItemView(String item){
        this.selectItem = item;
        notifyDataSetChanged();
    }
}
